package com.le.tester.javaThink.fifth.chapter14_StreamingProgramming;

import java.util.stream.Stream;

/**
 * 描述：使用流实现斐波那契数列
 */
public class Fibonacci {
    int x = 1;

    Stream<Integer> numbers() {
        return Stream.iterate(0, i -> {
            int result = x + i;
            x = i;
            return result;
        });
    }

    public static void main(String[] args) {
        new Fibonacci().numbers()
                //过滤前10个，
                .skip(10)
                //取前10个
                .limit(10)
                .forEach(System.out::println);

    }
}
